package com.yun.algorithmproblem.huaweiod;


public class RidCar {
    public void ridCar(String s, int capacity) {
        String[] split = s.split(",");
        int[] dp = new int[capacity + 1];
        dp[0]=1;
        for (String value : split) {
            int num = Integer.parseInt(value);
            System.out.println(num);
            int[] newDp = new int[capacity + 1];
            for (int j = 0; j < capacity + 1; j++) {
                if (num <= j) {
                    newDp[j] = dp[j] + dp[j - num];
                } else {
                    newDp[j] = dp[j];
                }
            }
            dp = newDp;
        }
        System.out.println(dp[capacity]);
    }

    public static void main(String[] args) {
        String s = "5,4,2,3,2,4,9";
        int capacity = 10;
        RidCar test = new RidCar();
        test.ridCar(s, capacity);
    }
}
